package com.todo.event.activity.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.event.activity.application.backend.service.EventDetailBackendService;
import com.todo.event.activity.iface.backend.EventDetailBackendIface;
import com.todo.event.activity.iface.backend.request.*;
import com.todo.event.activity.iface.backend.response.EventDetailResp;
import com.todo.event.activity.iface.backend.response.EventInfoResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2025/1/11 20:58
 * @description
 */
@RestController
@RequestMapping("/bd/event/detail")
@Tag(name = "事件详情配置后台处理类", description = "事件详情配置后台处理类")
public class EventDetailBackendController implements EventDetailBackendIface {

    @Resource
    private EventDetailBackendService eventDetailBackendService;

    @Override
    @Operation(summary = "新增事件详情")
    @PostMapping("/insertEventDetail")
    public BizResponse<Boolean> insertEventDetail(@RequestBody InsertEventDetailReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDetailBackendService.insertEventDetail(req);
    }

    @Override
    @Operation(summary = "更新事件详情")
    @PostMapping("/updateEventDetail")
    public BizResponse<Boolean> updateEventDetail(@RequestBody UpdateEventDetailReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDetailBackendService.updateEventDetail(req);
    }

    @Override
    @Operation(summary = "根据主键删除事件详情")
    @PostMapping("/removeEventDetailById")
    public BizResponse<Boolean> removeEventDetailById(@RequestBody RemoveEventDetailByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDetailBackendService.removeEventDetailById(req);
    }

    @Override
    @Operation(summary = "事件详情配置测试")
    @PostMapping("/testEventDetailProperty")
    public BizResponse<String> testEventDetailProperty(@RequestBody TestEventDetailPropertyReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDetailBackendService.testEventDetailProperty(req);
    }

    @Override
    @Operation(summary = "启用事件详情")
    @PostMapping("/enableEventDetail")
    public BizResponse<Boolean> enableEventDetail(@RequestBody EnableEventDetailReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDetailBackendService.enableEventDetail(req);
    }

    @Override
    @Operation(summary = "根据主键查询事件详情")
    @PostMapping("/queryEventDetailById")
    public BizResponse<EventDetailResp> queryEventDetailById(@RequestBody QueryEventDetailByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return eventDetailBackendService.queryEventDetailById(req);
    }

    @Override
    @Operation(summary = "分页查询事件基础信息")
    @PostMapping("/queryEventDetailPage")
    public BizPageResponse<EventInfoResp> queryEventDetailPage(@RequestBody QueryEventDetailPageReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return eventDetailBackendService.queryEventDetailPage(req);
    }
}
